<template>
  <div class="khy">
    <h6 class="khy-title">基本信息</h6>
    <section class="khy-container">
      <p>公司名称：{{ companyInfo.companyName || '--' }}</p>
      <p>统一社会征信编码：{{ companyInfo.uscCode || '--' }}</p>
      <p>注册时间：{{ companyInfo.registerDate || '--' }}</p>
      <p>注册地址：{{ companyInfo.registerAddress || '--' }}</p>
      <p>法人姓名：{{ companyInfo.legalName || '--' }}</p>
      <p>法人身份证号：{{ companyInfo.legalIdentity || '--' }}</p>
      <p style="width: 100%">法人身份证有效期：{{ companyInfo.legalIdentityPeriod || '--' }}</p>

      <div class="flex" style="width: 50%; margin-bottom: 10px">
        <p>营业执照：</p>
        <img
          style="width: 101px; height: 101px"
          v-if="companyInfo.businessLicensePath"
          :src="companyInfo.businessLicensePath"
          alt=""
          @click="openWindow(companyInfo.businessLicensePath)"
        />
        <p v-else>--</p>
      </div>
      <div class="flex" style="width: 50%; margin-bottom: 10px">
        <p>法人身份证：</p>
        <img
          style="width: 101px; height: 101px; margin-right: 20px"
          v-if="companyInfo.legalIdentityBackPath"
          :src="companyInfo.legalIdentityBackPath"
          alt=""
          @click="openWindow(companyInfo.legalIdentityBackPath)"
        />
        <p v-else>--</p>

        <img
          style="width: 101px; height: 101px"
          v-if="companyInfo.legalIdentityFrontPath"
          :src="companyInfo.legalIdentityFrontPath"
          alt=""
          @click="openWindow(companyInfo.legalIdentityFrontPath)"
        />
        <p v-else>--</p>
      </div>

      <p>入网时间：{{ companyInfo.licenceIssueTime || '--' }}</p>
      <p>信用评分等级：{{ companyInfo.scoreLevel || '--' }}</p>
      <p>企业成立时间：{{ companyInfo.registerDate || '--' }}</p>
    </section>
    <template v-if="khySign === '1'">
      <h6 class="khy-title">关联网络货运平台</h6>
      <section class="khy-container">
        <slot></slot>
      </section>
      <h6 class="khy-title">关联货主</h6>
      <section class="khy-container" v-if="relatedInfo.length > 0">
        <table border="1">
          <tr>
            <td>协议名称</td>
            <td>货主名称</td>
            <td>账期（天）</td>
          </tr>
          <tr :key="index" v-for="(item, index) in relatedInfo">
            <td>{{ item.protocolName }}</td>
            <td>{{ item.shipperName }}</td>
            <td>{{ item.accountPeriod }}</td>
          </tr>
        </table>
      </section>
    </template>
  </div>
</template>

<script>
export default {
  name: 'KhyCompanyInfo',
  props: {
    companyInfo: {
      type: Object,
    },
    relatedInfo: {
      type: Array,
    },
    khySign: {
      type: String,
    },
  },

  data() {
    return {}
  },
  methods: {
    openWindow(url) {
      window.open(url, '__blank')
    },
  },
}
</script>
